package com.wardrobe.soa.api.booking;

import com.wardrobe.domain.booking.BookingShowBean;
import com.wardrobe.soa.api.home.HomeInfoResponse;
import com.wardrobe.soa.common.ApiResult;
import com.wardrobe.soa.utils.CommonConsant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Administrator on 2018/11/19.
 */
@RestController
@RequestMapping("/api/booking")
public class BookingController {
    private static final Logger logger = LoggerFactory.getLogger(BookingController.class);
    @Autowired
    private BookingService bookingService;

    @RequestMapping("/bookingList")
    public ApiResult getBookingList(){
        try {
            List<BookingShowBean> list = bookingService.getBookingList();
            return new ApiResult(CommonConsant.successCode,CommonConsant.success,CommonConsant.successMsg,list);
        }catch (Exception e){
            logger.error("getBookingList",e);
        }
        return new ApiResult(CommonConsant.serverFailedCode,CommonConsant.failed,CommonConsant.serverFailedMsg,"");
    }
    @RequestMapping("/getBookingDetail")
    public ApiResult getBookingDetail(long id,double latitude,double longitude,long userId){
        try {
            BookingResponse bookingResponse = bookingService.bookingDetail(id, latitude, longitude,userId);
            return new ApiResult(CommonConsant.successCode,CommonConsant.success,CommonConsant.successMsg,bookingResponse);
        }catch (Exception e){
            logger.error("getBookingList",e);
        }
        return new ApiResult(CommonConsant.serverFailedCode,CommonConsant.failed,CommonConsant.serverFailedMsg,"");
    }
}
